package com.example.administrator.hqq.base;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment;

import com.example.administrator.hqq.R;

import java.util.ArrayList;
import java.util.List;

import io.rong.imkit.actions.IClickActions;
import io.rong.imkit.fragment.ConversationFragment;
import io.rong.imkit.widget.adapter.MessageListAdapter;
import io.rong.imlib.model.Message;

/**
 * @name: HQQ
 * @describe:
 * @author: 康海涛 QQ2541849981
 * @time: 2018/12/10 10:26
 * @remark:
 */
public class BaseConversationFragment extends ConversationFragment implements IClickActions{
    private OnClickConfirm onClickConfirm;
    @Override
    public boolean showMoreClickItem() {
        return super.showMoreClickItem();
    }
    public void setOnClickConfirm(OnClickConfirm onClickConfirm) {
        this.onClickConfirm = onClickConfirm;
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    public Drawable obtainDrawable(Context context) {
        return context.getDrawable(R.drawable.confirm) ;
    }

    @Override
    public List<IClickActions> getMoreClickActions() {
        ArrayList<IClickActions> iClickActions = new ArrayList<>();
        iClickActions.add(this);
        return iClickActions;
    }

    @Override
    public void onClick(Fragment fragment) {
        if (getCheckedMessages()!=null&&getCheckedMessages().size()>0)
        {
            if (onClickConfirm!=null)
            {
                onClickConfirm.onclick(getCheckedMessages());
            }
        }
    }
    public interface OnClickConfirm{
        void onclick(List<Message> messages);
    }
}
